﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <link href="~/css/shop.css" type="text/css" rel="stylesheet" />
    <link href="~/css/Sellerber.css" type="text/css" rel="stylesheet" />
    <link href="~/css/bkg_ui.css" type="text/css" rel="stylesheet" />
    <link href="~/font/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <script src="~/js/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="~/js/jquery.cookie.js"></script>
    <script src="~/js/shopFrame.js" type="text/javascript"></script>
    <script src="~/js/Sellerber.js" type="text/javascript"></script>
    <script src="~/js/layer/layer.js" type="text/javascript"></script>
    <script src="~/js/laydate/laydate.js" type="text/javascript"></script>
    <script type="text/javascript" src="~/js/proTree.js"></script>
    <link rel="stylesheet" href="~/layui/css/layui.css" />
    <script src="~/layui/layui.js" type="text/javascript"></script>
    <script src="~/Scripts/timeTranslation.js" type="text/javascript"></script>
    <!--[if lt IE 9]>
    <script src="js/html5shiv.js" type="text/javascript"></script>
    <script src="js/respond.min.js"></script>
    <script src="js/css3-mediaqueries.js"  type="text/javascript"></script>
      <![endif]-->
    <title>产品列表</title>
</head>
<body>
    <div class="margin" id="page_style">
        <div class="operation clearfix mb15 same_module">
            <ul class="choice_search">
                <li class="clearfix col-xs-3 col-lg-3 col-ms-3 "><label class="label_name ">产品名称：</label><input name="" type="text" class="form-control col-xs-8 col-lg-8 col-ms-8" /></li>
                <li class="clearfix col-xs-5 col-lg-5 col-ms-5 ">
                    <label class="label_name ">添加时间：</label>
                    <input class="laydate-icon col-xs-4 col-lg-3 form-control Select_Date" id="start" />
                    <span style=" float:left; padding:0px 10px; line-height:32px;">至</span>
                    <input class="laydate-icon col-xs-4 col-lg-3 form-control Select_Date" id="end" />
                    <button class="btn button_btn bg-deep-blue " onclick="" type="button"><i class="fa  fa-search"></i>&nbsp;搜索</button>
                </li>
            </ul>
        </div>
        <!--列表展示-->
        <div class="h_products_list clearfix" id="Sellerber">
            <div class="Sellerber_left menu" id="menuBar">
                <div class="show_btn" id="rightArrow"><span></span></div>
                <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
                <div class="menu_style" id="menu_style">
                    <div class="list_content">
                        <div class="side_list">
                            <div class="column_title"><h4 class="lighter smaller">产品类型列表</h4></div>
                            <div class="st_tree_style tree">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="list_Exhibition list_show padding15">
                <div class="operation clearfix mb15 searchs_style">
                    <button class="btn button_btn btn-danger" type="button" onclick=""><i class="fa fa-trash-o"></i>&nbsp;删除</button>
                    <span class="submenu">
                        <a href="add_product.html" name="" class="btn button_btn bg-deep-blue" title="添加产品"><i class="fa  fa-edit"></i>&nbsp;添加产品</a>
                        <a href="javascript:ovid()" id="Competence_add" name="" class="btn button_btn bg-deep-blue" title="添加分类"><i class="fa  fa-edit"></i>&nbsp;添加分类</a>
                    </span>
                    <div class="search  clearfix">
                        <label class="label_name">商品搜索：</label><input name="" type="text" class="form-control col-xs-5" /><button class="btn button_btn bg-deep-blue " onclick="" type="button"><i class="fa  fa-search"></i>&nbsp;搜索</button>
                        <span>数量：3433件</span>
                    </div>
                </div>
                <div class="datalist_show">
                    <div class="datatable_height confirm">
                        <table class="layui-hide" id="test" lay-filter="demo"></table>
                        <script id="barDemo" type="text/html">
                            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
                            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
                        </script>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!--添加权限样式-->
    <div id="Competence_add_style" style="display:none">
        <div class="Competence_add_style">
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="form-field-1">分类名称</label>
                <div class="col-sm-9"><input type="text" id="Name" placeholder="" name="分类名称" class="col-xs-10 col-sm-5" /></div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 父分类ID </label>
                <div class="col-sm-9"><input type="text" id="ParentId" placeholder="" name="父级菜单ID" class="col-xs-10 col-sm-5" /></div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label no-padding-right" for="form-field-1">分类层级</label>
                <div class="col-sm-9"><input type="text" id="CategoryLevel" placeholder="" name="名称" class="col-xs-10 col-sm-5" /></div>
            </div>
 
        </div>
    </div>
</body>
</html>
<script>
    layui.use('table', function () {
        var table = layui.table
            , form = layui.form;  //启用
        table.render({
            elem: '#test'
            , url: '/Products/GetProductsPageList'
            , cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            , cols: [[
                  { type: 'checkbox' }
                , { field: 'Id', width: 78, align: 'center', title: '产品ID', sort: true }
                , { field: 'Code', width: 78, align: 'center', title: '产品编号', sort: true }
                , { field: 'Name1', width: 75, align: 'center', title: '分类' }
                , { field: 'Name2', width: 80, align: 'center', title: '产品名称' }
                , { field: 'Price', width: 80, align: 'center', title: '价格' }
                , { field: 'InDate', width: 176, align: 'center', title: '加入时间', templet: "<div>{{Format(d.InDate,'yyyy-MM-dd')}}</div>" }
                , { field: 'Audit_Status', width: 78, align: 'center', title: '审核状态', sort: true}
                , { field: 'Publish_Status', width: 78, align: 'center', title: '状态', sort: true}              
                , { fixed: 'right', title: '操作', width: 208, align: 'center', toolbar: '#barDemo' }
            ]]
            , page: true
            , id: 'testReload'
        });
         //监听工具
        table.on('tool(demo)', function (obj) {
            var data = obj.data;
            var id = data.Pic_Id;
            //删除
            if (obj.event === 'del') {
                var datas = {};
                datas.Pic_Id = id;
                layer.confirm('确认删除行？', function (index) {
                $.ajax({
                    url: "/Pic/DelPic",
                    data: datas,
                    type: "post",
                    success: function (result) {
                       if (result.Success) {
                           layer.msg("删除成功");
                           location.reload();
                        }
                        else {
                           layer.msg("删除失败");
                        }
                    }
                })
                });
            //编辑
            } else if (obj.event === 'edit') {
                //通过控制器传值
                window.location.href='/Home/Price_update?id='+id
            }
        });
    });
    
</script>
<script type="text/javascript">
    /*添加权限*/
    $('#Competence_add').on('click', function () {
        //Empty();
        layer.open({
            type: 1,
            title: '添加分类',
            maxmin: true,
            shadeClose: false,
            area: ['800px', ''],
            content: $('#Competence_add_style'),
            btn: ['提交', '取消'],
            yes: function (index, layero) {
                var num = 0;
                var str = "";
                $(".col-sm-9 input[type$='text'],#form_textarea").each(function (n) {
                    if ($(this).val() == "") {
                        layer.alert(str += "" + $(this).attr("name") + "不能为空！\r\n", {
                            title: '提示框',
                            icon: 0,
                        });
                        num++;
                        return false;
                    }
                });
                if (num > 0) { return false; }
                else {
                    //添加
                    var category = {};                   
                    category.Name = $("#Name").val();               
                    category.ParentId = $("#ParentId").val();
                    category.CategoryLevel = $("#CategoryLevel").val();
                    if (category.Name != null) {
                        $.ajax({
                            url: "/Products/SelectCategoryName?name=" + category.Name,
                            type: "post",
                            success: function (result) {
                                if (result.Success) {
                                    layer.msg("已存在" + category.Name, { icon: 0, time: 2500, title: "提示" });
                                }
                                else {
                                    $.ajax({
                                        url: "/Products/AddingInformation",
                                        type: "post",
                                        data: category,
                                        success: function (result) {
                                            if (result.Success) {
                                                layer.msg("添加成功", { icon: 1, time: 2500, title: "提示" });
                                                location.reload();//刷新页面
                                            }
                                            else {
                                                layer.msg("添加失败", { icon: 0, time: 2500, title: "提示" });
                                            }
                                        }
                                    })
                                }
                            }
                        })
                    }
                }
            }
        });
    });
</script>
